package com.group9.handinhand.controller.form;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;

import com.group9.handinhand.service.so.ActivityEnums.ActivityType;
import com.group9.handinhand.service.so.EventSO;
import com.group9.handinhand.service.so.TagSO;
import com.group9.handinhand.service.so.UserSO;
/**
 * 
 * @class EventUpdateForm
 * In this class updates the event form
 *
 */
public class EventUpdateForm {
	
	EventSO event;
	List<UserSO> moderators;
	String selectedTags;
	String startingDay;
	String startingHour;
	String endingDay;
	String endingHour;
	
	
	public EventUpdateForm() {
		// TODO Auto-generated constructor stub
	}
	/**
	 * A getter method.
	 * @return startingDay
	 */
	public String getStartingDay() {
		return startingDay;
	}
	/**
	 * A setter method.
	 * @param startingDay
	 */
	public void setStartingDay(String startingDay) {
		this.startingDay = startingDay;
	}
	/**
	 * A getter method.
	 * @return startingHour
	 */
	public String getStartingHour() {
		return startingHour;
	}
	/**
	 * A setter method.
	 * @param startingHour
	 */
	public void setStartingHour(String startingHour) {
		this.startingHour = startingHour;
	}
	/**
	 * A getter method
	 * @return	endindgDay
	 */
	public String getEndingDay() {
		return endingDay;
	}
	/**
	 * A setter method.
	 * @param endingDay
	 */
	public void setEndingDay(String endingDay) {
		this.endingDay = endingDay;
	}
	/**
	 * A getter method.
	 * @return	endingHour
	 */
	public String getEndingHour() {
		return endingHour;
	}
	/**
	 * A setter method.
	 * @param endingHour
	 */
	public void setEndingHour(String endingHour) {
		this.endingHour = endingHour;
	}
	/**
	 * A getter method.
	 * @return	a list of moderators.
	 */
	public List<UserSO> getModerators() {
		return moderators;
	}
	/**
	 * A setter method.
	 * @param moderators
	 */
	public void setModerators(List<UserSO> moderators) {
		this.moderators = moderators;
	}
	/**
	 * A getter method.
	 * @return event
	 */
	public EventSO getEvent() {
		return event;
	}
	/**
	 * A setter method.
	 * @param event
	 */
	public void setEvent(EventSO event) {
		this.event = event;
	}
	/**
	 * A getter method.
	 * @return	selectedTags
	 */
	public String getSelectedTags() {
		return selectedTags;
	}
	/**
	 * A setter method.
	 * @param selectedTags
	 */
	public void setSelectedTags(String selectedTags) {
		this.selectedTags = selectedTags;
	}
	/**
	 * A getter method.
	 * @return a list of selected tags
	 */
	public List<String> getSelectedTagsAsList() {
		String[] tags = selectedTags.split(",");
		return Arrays.asList(tags);
	}
	/**
	 * A setter method.
	 * Sets the all tags as a list.
	 * @param soList
	 */
	public void setSelectedTagsFromList(List<TagSO> soList) {
		selectedTags = "";
		if(soList.size()==0)
			return;
		selectedTags += soList.get(0).getTagName();
		soList.remove(0);
		for (TagSO tag : soList) {
			selectedTags += ", " + tag.getTagName();
		}
	}
	/**
	 * A set method.
	 * Sets the starting and ending dates which include starting and ending days and hours also.
	 */
	public void setStartAndEndDates() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		
		String startingDate = startingDay + " " + startingHour;
		String endingDate = endingDay + " " + endingHour;
		
		try {
			event.setStartingTime(dateFormat.parse(startingDate));
			event.setEndingTime(dateFormat.parse(endingDate));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}
}
